from typing import List


def longestSubsequence(arr: List[int], difference: int) -> int:
    n = len(arr)
    dp = [1] * n
    index_v = dict()
    result = 1
    index_v[arr[0]] = 0
    for i in range(1, n):

        if arr[i] - difference in index_v:
            targrt_index = index_v[arr[i] - difference]
            dp[i] = dp[targrt_index] + 1

        result = max(result, dp[i])
        index_v[arr[i]] = i
    return result


if __name__ == '__main__':
    p = longestSubsequence([7, 7, 7, 7, 7, 7, 7], 0)
    print(p)
